package com.sc.nft.service.impl;

import com.sc.nft.dao.EcologyPoolRelationConditionBindDao;
import com.sc.nft.entity.EcologyPoolRelationConditionBind;
import com.sc.nft.enums.EcologyPoolRelationConditionBindTypeEnum;
import com.sc.nft.enums.EcologyPoolRelationTypeEnum;
import com.sc.nft.exception.GlobalRunTimeException;
import com.sc.nft.service.EcologyPoolRelationConditionBindService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 刘国航
 * @since 2024/8/10 16:23
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class EcologyPoolRelationConditionBindServiceImpl implements EcologyPoolRelationConditionBindService {

    private final EcologyPoolRelationConditionBindDao ecologyPoolRelationConditionBindDao;

    @Override
    public void saveRedPackNftBind(List<EcologyPoolRelationConditionBind> ecologyPoolRedPackRelationDTOS) {
        int i = ecologyPoolRelationConditionBindDao.saveRedPackNftBind(ecologyPoolRedPackRelationDTOS);
        if (i <= 0) {
            throw new GlobalRunTimeException("红包藏品关联保存失败");
        }
    }

    @Override
    public List<EcologyPoolRelationConditionBind> listByRedPackBind(Long bindId) {
        return ecologyPoolRelationConditionBindDao.getListByBind(bindId, EcologyPoolRelationConditionBindTypeEnum.RED_PACK, EcologyPoolRelationTypeEnum.COLLECTION);
    }
}
